﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StandardManager.DBItems
{
    internal class Books
    {
        public string FileName;
        public string BookName;
        public string Code;
        public string Desc;

        internal static Books FromDataRow(DataRow dataRow)
        {
            Books books = new Books()
            {
                FileName = dataRow["fileName"] as string,
                BookName = dataRow["bookName"] as string,
                Code = dataRow["code"] as string,
                Desc = dataRow["desc"] as string,
            };
            return books;
        }

        internal static string GetAllBooksSql()
        {
            return "select * from books";
        }

        public string BuildInsertSql()
        {
            var str = "insert into books(fileName,bookName,code,desc) values('{0}','{1}','{2}','{3}')";
            return String.Format(str, FileName, BookName,Code,Desc);
        }
    }

    public class BooksList
    {
        internal List<Books> Items=new List<Books>();

        public static BooksList Instances=new BooksList();
    }
}
